home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / Tools / freeWAIS-sf-1.1 / x / display.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-04  |  6.3 KB  |  230 lines

  1. /* WIDE AREA INFORMATION SERVER SOFTWARE:
  2.    No guarantees or restrictions.  See the readme file for the full standard
  3.    disclaimer.
  4.  
  5.    This is part of the X user-interface for the WAIS software.  Do with it
  6.    as you please.
  7.  
  8.    jonathan@Think.COM
  9. */
  10.  
  11. /* Copyright (c) CNIDR (see ../COPYRIGHT) */
  12.  
  13. /*
  14.  * $Log: display.c,v $
  15.  * Revision 1.2  1994/08/05  07:30:57  pfeifer
  16.  * Release beta 04
  17.  *
  18.  * Revision 1.1  1993/02/16  15:10:18  freewais
  19.  * Initial revision
  20.  *
  21.  * Revision 1.5  92/04/28  15:25:21  jonathan
  22.  * Changed use of Scrolllist.
  23.  * 
  24.  * Revision 1.4  92/03/17  14:16:13  jonathan
  25.  * Generally cleaned things up.
  26.  * 
  27.  */
  28.  
  29. #ifndef lint
  30. static char *RCSid = "$Header: /usr/local/ls6/src+data/src/freeWAIS-sf/x/RCS/display.c,v 1.2 1994/08/05 07:30:57 pfeifer Exp $";
  31. #endif
  32.  
  33. #define XWAIS
  34. #include "xwais.h"
  35.  
  36. static ScrollList
  37. MakeQuestionFrame(parent)
  38. Widget parent;
  39. {
  40.   Widget frame, labelwid, button;
  41.   Widget view;
  42.   ScrollList result;
  43.   Arg arglist[TWO];
  44.   Cardinal num_args;
  45.  
  46.   frame = XtCreateManagedWidget("questions", formWidgetClass, parent, NULL, ZERO);
  47.  
  48.   labelwid = MakeLabel(frame, "questionlabel", "Questions:", NULL, NULL);
  49.  
  50.   num_args = 0;
  51. #ifndef MOTIF
  52.   XtSetArg (arglist[ZERO], XtNforceBars, True);
  53.   XtSetArg (arglist[ONE], XtNallowVert, True);
  54.   num_args = 2;
  55. #endif
  56.   view = XtCreateManagedWidget ("qview", viewportWidgetClass,
  57.                 frame, arglist, num_args);
  58.  
  59.   result =
  60.     MakeScrollList(view, "questionWindow", Question_items, 
  61.            EditQuestion, NULL, NULL);
  62.  
  63.   button = MakeCommandButton(frame, "qadd", AddQuestion,
  64.                  view, NULL, NULL);
  65.   button = MakeCommandButton(frame, "qedit", EditQuestion,
  66.                  view, NULL, NULL);
  67.   button = MakeCommandButton(frame, "qdelete", DeleteQuestion,
  68.                  view, NULL, NULL);
  69.   return result;
  70. }
  71.  
  72. static ScrollList
  73. MakeSourceFrame(parent)
  74. Widget parent;
  75. {
  76.   Widget frame, labelwid, button, view;
  77.   ScrollList result;
  78.   Arg arglist[TWO];
  79.   Cardinal num_args;
  80.  
  81.   frame = XtCreateManagedWidget("tsources", formWidgetClass, parent, NULL, ZERO);
  82.  
  83.   labelwid = MakeLabel(frame, "sourcelabel", "Sources:", NULL, NULL);
  84.  
  85.   num_args = 0;
  86. #ifndef MOTIF
  87.   XtSetArg (arglist[ZERO], XtNforceBars, True);
  88.   XtSetArg (arglist[ONE], XtNallowVert, True);
  89.   num_args = 2;
  90. #endif
  91.   view = XtCreateManagedWidget ("tsview", viewportWidgetClass,
  92.                 frame, arglist, num_args);
  93.  
  94.   result =
  95.     MakeScrollList(view, "sourceWindow", Source_items, 
  96.            EditSource, NULL, NULL);
  97.  
  98.   button = MakeCommandButton(frame, "sadd", AddSource,
  99.                  view, NULL, NULL);
  100.   button = MakeCommandButton(frame, "sedit", EditSource,
  101.                  view, NULL, NULL);
  102.   button = MakeCommandButton(frame, "sdelete", DeleteSource,
  103.                  view, NULL, NULL);
  104.   return result;
  105. }
  106.  
  107. static Widget
  108. MakeMessage(parent)
  109. Widget parent;
  110. {
  111.   Widget stringlabelwid;
  112.   Arg arglist[10];
  113.   Cardinal num_args;
  114.  
  115.   stringlabelwid = MakeLabel(parent, "mainstatuslabel", "Status:",
  116.                  NULL, NULL);
  117.   num_args = 0;
  118.   XtSetArg(arglist[num_args], XtNeditType, XawtextEdit); num_args++;
  119.   XtSetArg(arglist[num_args], XtNsensitive, False); num_args++;
  120.   XtSetArg(arglist[num_args], XtNfromVert, stringlabelwid); num_args++;
  121.   return XtCreateManagedWidget("messageWindow", asciiTextWidgetClass,
  122.                    parent, arglist, num_args);
  123. }
  124.  
  125. static Widget
  126. MakeSourcePopup(parent)
  127. Widget parent;
  128. {
  129.   Arg args[THREE];
  130.   Widget shell, frame, labelwid, stringlabelwid, button, tmp;
  131.   static String
  132.     namestring,
  133.     serverstring,
  134.     servicestring,
  135.     dbstring,
  136.     cost, units,
  137.     maintainer,
  138.     description;
  139.   int CurrentSource;
  140.   Source source;
  141.  
  142.   CurrentSource = get_selected_source();
  143.  
  144.   if (CurrentSource != NO_ITEM_SELECTED) {
  145.     source = findSource(CurrentSource);
  146.     namestring = source->name;
  147.     serverstring = source->server;
  148.     servicestring = source->service;
  149.     dbstring = source->database;
  150.     cost = source->cost;
  151.     units = source->units;
  152.     maintainer = source->maintainer;
  153.     description = source->description;
  154.   } else {
  155.     namestring = "default";
  156.     serverstring = "localhost";
  157.     servicestring = "8000";
  158.     dbstring = "";
  159.     cost = "";
  160.     units = "";
  161.     maintainer = "";
  162.     description = "";
  163.   }
  164.  
  165.   shell = XtCreatePopupShell("sourcepopup", applicationShellWidgetClass,
  166.                  parent, NULL, ZERO);
  167.   frame = XtCreateManagedWidget("sourcepopupform", formWidgetClass,
  168.                 shell, NULL, ZERO);
  169.  
  170.   stringlabelwid = MakeLabel(frame, "sourcenamelabel", "       Name:", NULL, NULL);
  171.   tmp = snamewid = MakeStringBox(frame, "sourcename", namestring, NULL, stringlabelwid);
  172.  
  173.   stringlabelwid = MakeLabel(frame, "serverlabel",     "     Server:", tmp, NULL);
  174.   tmp = serverwid = MakeStringBox(frame, "server", serverstring, tmp, stringlabelwid);
  175.  
  176.   stringlabelwid = MakeLabel(frame, "servicelabel", "    Service:", tmp, NULL);
  177.   tmp = servicewid = MakeStringBox(frame, "service", serverstring, tmp, stringlabelwid);
  178.  
  179.   stringlabelwid = MakeLabel(frame, "dblabel",      "   Database:", tmp, NULL);
  180.   tmp = dbwid = MakeStringBox(frame, "database", dbstring, tmp, stringlabelwid);
  181.  
  182.   stringlabelwid = MakeLabel(frame, "costlabel",    "       Cost:", tmp, NULL);
  183.   tmp = costwid = MakeStringBox(frame, "cost", cost, tmp, stringlabelwid);
  184.  
  185.   stringlabelwid = MakeLabel(frame, "unitlabel",    "      Units:", tmp, NULL);
  186.   tmp = unitwid = MakeStringBox(frame, "costunit", units, tmp, stringlabelwid);
  187.  
  188.   stringlabelwid = MakeLabel(frame, "maintlabel",   " Maintainer:", tmp, NULL);
  189.   tmp = maintainerwid = MakeStringBox(frame, "maintainer", maintainer, tmp, stringlabelwid);
  190.  
  191.   stringlabelwid = MakeLabel(frame, "desclabel",    "Description:", tmp, NULL);
  192.  
  193.   XtSetArg(args[ZERO], XtNeditType, XawtextEdit);
  194.   XtSetArg(args[ONE], XtNstring, description);
  195.   XtSetArg(args[TWO], XtNfromVert, stringlabelwid);
  196.  
  197.   tmp = descwid = 
  198.     XtCreateManagedWidget("description", asciiTextWidgetClass, frame, args, THREE);
  199.  
  200.   button = MakeCommandButton(frame, "sdone", CloseSourceEdit, tmp, NULL, NULL);
  201.   MakeCommandButton(frame, "cancel", CancelSourceEdit, tmp, button, NULL);
  202.  
  203.   return shell;
  204. }
  205.  
  206. Widget
  207. SetupWaisDisplay(parent)
  208. Widget parent;
  209. {
  210.   Widget form, button;
  211.  
  212.   form = XtCreateManagedWidget ("form", formWidgetClass,
  213.                 parent, NULL, ZERO);
  214.  
  215.   questionwindow = MakeQuestionFrame(form);
  216.  
  217.   sourcewindow = MakeSourceFrame(form);
  218.  
  219.   button = MakeCommandButton(form, "help", XwaisHelp,
  220.                  NULL, NULL, NULL);
  221.  
  222.   MakeCommandButton(form, "quit", DoQuit, NULL, button, NULL);
  223.  
  224.   messwidget = MakeMessage(form);
  225.  
  226.   sourcepopup = MakeSourcePopup(top);
  227.  
  228.   return form;
  229. }
  230.